/*
 *  HazardQueue.h
 *  pcm
 *
 *  Created by Yanick Candaux on 17.12.11.
 *  Copyright 2011 Heig-vd. All rights reserved.
 *
 */

#ifndef HAZARDQUEUE_H_
#define HAZARDQUEUE_H_

#include "BoardInfos.hpp"
#include "Node.h"
#include <cstring>
//#include <stm/config.h>
//#include <stdint.h>
//#include <limits>
#include "def.hpp"


#define NUMTHREADS 4 //A mettre dans une autre classe

using namespace std;

namespace pcm {
	
	class HazardQueue {
		
		
		
		
	public:
		
		Node *HP[NUMTHREADS][2];
		Node *LocalQueues[NUMTHREADS][2];
		
		Node *Head;
		Node *Tail;
		Node *Blop;
		
		bool initializeQueue();
		void initializeHazardPointers(void);
		bool enq(BoardInfos *value, unsigned threadID);
		BoardInfos *deq(unsigned threadID);
		void freeNode(Node *node,unsigned tid);
		Node *getFreeNode(unsigned tid);
		bool isReferenced(Node *node);
		
		
	protected:
		
		
		
		
	private:
		
	};	
} /* namespace pcm */
#endif /* HAZARDQUEUE_H_ */
